package com.onlyphoto.onlymall.mvp.view.activity

import androidx.recyclerview.widget.LinearLayoutManager
import com.onlyphoto.onlymall.R
import com.onlyphoto.onlymall.base.BaseActivity
import com.onlyphoto.onlymall.bean.request.ExpressBean
import com.onlyphoto.onlymall.bean.response.LogisticsBean
import com.onlyphoto.onlymall.mvp.contract.CLogistics
import com.onlyphoto.onlymall.mvp.presenter.PLogisticsImpl
import com.onlyphoto.onlymall.mvp.view.adapter.LogisticsInfoAdapter
import kotlinx.android.synthetic.main.activity_logistics.*

class LogisticsActivity : BaseActivity<PLogisticsImpl>(), CLogistics.IVLogistics {

    private var layoutManager: LinearLayoutManager? = null

    private var mAdapter: LogisticsInfoAdapter? = null

    override fun retry() {}

    override fun init() {
        initRv()
    }

    fun initRv(){
        layoutManager = LinearLayoutManager(this)
        rv_logistics.layoutManager = layoutManager
    }

    override fun initListener() {
        //点击事件初始化
        back.setOnClickListener{
            finish()
        }
    }

    override fun loadData() {
        mPresenter?.getLogistics()
    }

    override fun setExpress(): ExpressBean {
        val expressBean = ExpressBean()
        expressBean.express_company_py = intent.getStringExtra("expressCompanyPy")!!
        expressBean.express_num = intent.getStringExtra("expressNum")!!
        return expressBean
    }

    override fun getLogisticsSuccess(list: ArrayList<LogisticsBean>) {
        mAdapter = LogisticsInfoAdapter(this, list)
        rv_logistics.adapter = mAdapter
    }

    override fun isFullScreen(): Boolean {
        //是否沉浸式， 默认非沉浸式
        return false
    }

    public override fun initCustomerStatusManager() {

    }

    override fun setContentViewId(): Int {
        return R.layout.activity_logistics
    }

    override fun createPresenter() {
        mPresenter = PLogisticsImpl(mContext, this)
    }

    override fun showLoading() {

    }

    override fun hideLoading() {

    }

}
